Solutions: Mathematica 6 Lab 4

Problem 1:

DSolve[y'[x]==-Cos[x]y[x],y[x],x]

somesolutions=Table[(E^(-Sin[x])) C[1]/.C[1]->i,{i,-5,5}]

Plot[somesolutions,{x,0,4π},Ticks->{{0,π,2π,3π,4π},Automatic}]

Problem 2:

DSolve[x''[t]+((1/3)((x'[t])^2)-1)x'[t]+x[t]==0,x[t],t]

violin1=x[t]/.First[NDSolve[{x''[t]+((1/3)((x'[t])^2)-1)x'[t]+x[t]==0,x[0]==0.1,x'[0]==0},x[t],{t,0,15}]]
violin2=x[t]/.First[NDSolve[{x''[t]+((1/3)((x'[t])^2)-1)x'[t]+x[t]==0,x[0]==1.0,x'[0]==0},x[t],{t,0,15}]]
violin3=x[t]/.First[NDSolve[{x''[t]+((1/3)((x'[t])^2)-1)x'[t]+x[t]==0,x[0]==1.9,x'[0]==0},x[t],{t,0,15}]]

Plot[{violin1,violin2,violin3},{t,0,15},
PlotStyle->{Red,Blue,Black}]

Problem 3:

hardspring1=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==1},x[t],{t,0,15}]]
hardspring2=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==2},x[t],{t,0,15}]]
hardspring3=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==3},x[t],{t,0,15}]]
hardspring4=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==4},x[t],{t,0,15}]]
hardspring5=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==5},x[t],{t,0,15}]]

colorcod={Blue,Green,Orange,Red,Black}

Plot[Evaluate[{hardspring1,hardspring2,hardspring3,hardspring4,hardspring5}],{t,0,15},PlotStyle->colorcode]

Clear[x,t,v]

hardspring[v_]:=x[t]/.First[NDSolve[{x''[t]+0.3x[t]+0.04((x[t])^3)==0,x[0]==0,x'[0]==v},x[t],{t,0,15}]]

Manipulate[Plot[Evaluate[hardspring[v]],{t,0,15}, PlotRange->{-6,6}, PlotStyle->{Red,Thick}],{v,1,5}]

Problem 4:

tired1=x[t]/.First[DSolve[{x''[t]+4(E^(-t/4))x[t]==0,x'[0]==0,x[0]==1},x[t],t]]
tired2=x[t]/.First[DSolve[{x''[t]+4(E^(-t/4))x[t]==0,x'[0]==0,x[0]==2},x[t],t]]
tired3=x[t]/.First[DSolve[{x''[t]+4(E^(-t/4))x[t]==0,x'[0]==0,x[0]==3},x[t],t]]
tired4=x[t]/.First[DSolve[{x''[t]+4(E^(-t/4))x[t]==0,x'[0]==0,x[0]==4},x[t],t]]
tired5=x[t]/.First[DSolve[{x''[t]+4(E^(-t/4))x[t]==0,x'[0]==0,x[0]==5},x[t],t]]

Plot[Evaluate[{tired1,tired2,tired3,tired4,tired5}],{t,0,30},PlotStyle->colorcode]

Problem 5:

DSolve[x''[t]+(1+0.2Sin[2t])x[t]==0,x[t], t]

stimulated=x[t]/.NDSolve[{x''[t]+(1+.2Sin[2t])x[t]==0,
x'[0]==0,x[0]==1},x[t],{t,0,50}]
unstimulated=x[t]/.NDSolve[{x''[t]+(1+0.0Sin[2t])x[t]==0,
x'[0]==0,x[0]==1},x[t],{t,0,50}]

Plot[{stimulated,unstimulated},{t,0,50},PlotRange->All,PlotStyle->{{},Red}]

outofsync=x[t]/.NDSolve[{x''[t]+(1+0.2Sin[2.2t])x[t]==0,
x'[0]==0,x[0]==1},x[t],{t,0,50}]

Plot[{outofsync,unstimulated},{t,0,50},
PlotStyle->{{},Red}]